#!coding=utf-8
from django.db import models
import settings

# 企业基本信息  表一
class Enterprise(models.Model):
    name = models.CharField(u"企业名称",max_length=30)
    disable = models.CharField(u"是否禁用",max_length=30)

# 报告表封面
class Report_cover(models.Model):
    province = models.CharField(u'省',max_length = 30)
    city = models.CharField(u'市',max_length = 30)
    county = models.CharField(u'县',max_length = 30)
    enterprise_name = models.CharField(u"企业名称(公章)",max_length=30)
    organization_code = models.CharField(u'组织机构代码',max_length = 30)
    legal_representative = models.CharField(u'法定代表人',max_length = 30)
    contact = models.CharField(u'联系人',max_length = 30)
    phone = models.CharField(u'电话',max_length = 30)
    register_No = models.CharField(u'登记证号',max_length = 30)
    register_year = models.CharField(u'填报年度',max_length = 30)
    register_date = models.CharField(u'填报日期',max_length = 30)
    enterprise = models.ForeignKey(Enterprise)

    def getObj(self):
        _dict ={}
        _dict["id"] = self.id
        _dict["province"] = self.province
        _dict["city"] = self.city
        _dict["county"] = self.county
        _dict["enterprise_name"] = self.enterprise_name
        _dict["organization_code"] = self.organization_code
        _dict["legal_representative"] = self.legal_representative
        _dict["contact"] = self.contact
        _dict["phone"] = self.phone
        _dict["register_No"] = self.register_No
        _dict["register_year"] = self.register_year
        _dict["register_date"] = self.register_date
        return  _dict


class BasicInformation(models.Model):
    #第一部分
    enterprise_name = models.CharField(u"企业名称",max_length=30)
    organization_code = models.CharField(u'组织机构代码',max_length = 30)
    register_No = models.CharField(u'登记证号',max_length = 30)
    expiration = models.CharField(u'有效期限',max_length = 30)
    facilities_add = models.CharField(u'生产设施地址',max_length = 30)
    administrative_area_code = models.CharField(u"行政区划代码",max_length=20)
    postal_code = models.CharField(u'邮政编码',max_length = 30)
    industry_name = models.CharField(u"行业分类名称",max_length=20)
    industry_code = models.CharField(u'行业分类代码',max_length = 30)

    fill_form_person = models.CharField(u'填表人',max_length = 30)
    fill_from_date = models.CharField(u'填表日期',max_length = 30)
    enterprise = models.ForeignKey(Enterprise)
    def getObj(self):
        _dict ={}
        _dict["id"] = self.id
        _dict["enterprise_name"] = self.enterprise_name
        _dict["organization_code"] = self.organization_code
        _dict["register_No"] = self.register_No
        _dict["expiration"] = self.expiration
        _dict["facilities_add"] = self.facilities_add
        _dict["administrative_area_code"] = self.administrative_area_code
        _dict["postal_code"] = self.postal_code
        _dict["industry_name"] = self.industry_name
        _dict["industry_code"] = self.industry_code
        _dict["fill_form_person"] = self.fill_form_person
        _dict["fill_from_date"] = self.fill_from_date
        return _dict


class  Major_chemicals(models.Model):
    #重点环境管理危险化学品
    major_chemical_name = models.CharField(u'重点环境管理危险化学品品名',max_length = 30)

    type_produce = models.CharField(u"活动类型",max_length=30)
    ability = models.CharField(u'生产能力',max_length = 30)
    last_year_production = models.CharField(u"上年度产量",max_length=20)

    type_use = models.CharField(u"活动类型",max_length=30)
    design_use = models.CharField(u'设计使用量',max_length = 30)
    last_year_use = models.CharField(u"上年度用量",max_length=20)

    enterprise = models.ForeignKey(Enterprise)

    def getObj(self):
        _dict ={}
        _dict["id"] = self.id
        _dict["major_chemical_name"] = self.major_chemical_name
        _dict["type_produce"] = self.type_produce
        _dict["ability"] = self.ability
        _dict["last_year_production"] = self.last_year_production

        _dict["type_use"] = self.type_use
        _dict["design_use"] = self.design_use
        _dict["last_year_use"] = self.last_year_use
        return _dict



# 重点环境管理危险化学品及其特征化学污染物释放与转移情况
#  表二的第一部分
class Release_transfer_information(models.Model):
# 重点环境管理危险化学品及其特征化学污染物释放与转移信息
    major_chemical_name = models.CharField(u'重点环境管理危险化学品品名或其特征化学污染物名称',max_length = 30)
    belong = models.CharField(u'属于',max_length = 30)
    #释放大气
    organized_emissions = models.CharField(u'有组织排放',max_length = 30)
    release_amount = models.CharField(u'释放量(千克/年)',max_length = 30)
    release_concentration = models.CharField(u'释放浓度(毫克/升)',max_length = 30)
    calculate_code = models.CharField(u'核算方法代码',max_length = 30)

    unorganized_emissions = models.CharField(u"无组织排放",max_length=20)
    unorganized_release_amount = models.CharField(u'释放量(千克/年)',max_length = 30)
    unorganized_release_concentration = models.CharField(u'释放浓度(毫克/升)',max_length = 30)
    unorganized_calculate_code = models.CharField(u'核算方法代码',max_length = 30)

    subtotal = models.CharField(u'小计',max_length = 30)
    #释放水体
    receiving_water_name = models.CharField(u"受纳水体名称",max_length=20)
    receiving_water_code = models.CharField(u'受纳水体代码',max_length = 30)
    water_release_amount = models.CharField(u'释放量(千克/年)',max_length = 30)
    water_release_concentration = models.CharField(u'释放浓度(毫克/升)',max_length = 30)
    water_calculate_code = models.CharField(u'核算方法代码',max_length = 30)
    #释放土壤
    landfill = models.CharField(u'自行填埋',max_length = 30)
    soil_release_amount = models.CharField(u'释放量(千克/年)',max_length = 30)
    soil_release_concentration = models.CharField(u'释放浓度(毫克/升)',max_length = 30)
    soil_calculate_code = models.CharField(u'核算方法代码',max_length = 30)

    other = models.CharField(u"其它",max_length=20)
    soil_other_release_amount = models.CharField(u'释放量(千克/年)',max_length = 30)
    soil_other_release_concentration = models.CharField(u'释放浓度(毫克/升)',max_length = 30)
    soil_other_calculate_code = models.CharField(u'核算方法代码',max_length = 30)

    soil_subtotal = models.CharField(u'小计',max_length = 30)
    release_total = models.CharField(u'合计',max_length = 30)
    #转移情况
    #转移到污水处理厂
    transfer_amount = models.CharField(u'转移量(千克/年)',max_length = 30)
    processing_factory_name = models.CharField(u'污水处理厂名称',max_length = 30)
    processing_factory_add = models.CharField(u'污水处理厂地址',max_length = 30)
    processing_factory_calculate_code = models.CharField(u'核算方法代码',max_length = 30)
    #转移到危险固废处理单位
    solid_name = models.CharField(u"固体废物名称",max_length=20)
    solid_state= models.CharField(u'固体废物形态',max_length = 30)
    solid_transfer_amount  = models.CharField(u'转移量(千克/年)',max_length = 30)
    solid_calculate_code = models.CharField(u'核算方法代码',max_length = 30)
    solid_processing_unit_name = models.CharField(u'处置单位名称',max_length = 30)
    license_number  = models.CharField(u'危险废物经营许可证编号',max_length = 30)
    solid_subtotal = models.CharField(u'小计',max_length = 30)
    tranfer_total = models.CharField(u'合计',max_length = 30)

    fill_name = models.CharField(u'填表人',max_length = 30)
    fill_date = models.CharField(u'填表日期',max_length = 30)


    calculate_id = models.CharField(u'计算',max_length = 30)
    enterprise = models.ForeignKey(Enterprise)

    def getObj(self):
        _dict ={}
        _dict["id"] = self.id

        _dict["major_chemical_name"] = self.major_chemical_name
        _dict["belong"] = self.belong
        _dict["organized_emissions"] = self.organized_emissions
        _dict["release_amount"] = self.release_amount
        _dict["release_concentration"] = self.release_concentration
        _dict["calculate_code"] = self.calculate_code
        _dict["unorganized_emissions"] = self.unorganized_emissions
        _dict["unorganized_release_amount"] = self.unorganized_release_amount
        _dict["unorganized_release_concentration"] = self.unorganized_release_concentration
        _dict["unorganized_calculate_code"] = self.unorganized_calculate_code
        _dict["subtotal"] = self.subtotal

        _dict["receiving_water_name"] = self.receiving_water_name
        _dict["receiving_water_code"] = self.receiving_water_code
        _dict["water_release_amount"] = self.water_release_amount
        _dict["water_release_concentration"] = self.water_release_concentration
        _dict["water_calculate_code"] = self.water_calculate_code

        _dict["landfill"] = self.landfill
        _dict["soil_release_amount"] = self.soil_release_amount
        _dict["soil_release_concentration"] = self.soil_release_concentration
        _dict["soil_calculate_code"] = self.soil_calculate_code
        _dict["other"] = self.other
        _dict["soil_other_release_amount"] = self.soil_other_release_amount
        _dict["soil_other_release_concentration"] = self.soil_other_release_concentration
        _dict["soil_other_calculate_code"] = self.soil_other_calculate_code
        _dict["soil_subtotal"] = self.soil_subtotal
        _dict["release_total"] = self.release_total

        _dict["transfer_amount"] = self.transfer_amount
        _dict["processing_factory_name"] = self.processing_factory_name
        _dict["processing_factory_add"] = self.processing_factory_add
        _dict["processing_factory_calculate_code"] = self.processing_factory_calculate_code
        _dict["solid_name"] = self.solid_name
        _dict["solid_state"] = self.solid_state
        _dict["solid_transfer_amount"] = self.solid_transfer_amount
        _dict["solid_calculate_code"] = self.solid_calculate_code
        _dict["solid_processing_unit_name"] = self.solid_processing_unit_name
        _dict["license_number"] = self.license_number
        _dict["solid_subtotal"] = self.solid_subtotal
        _dict["tranfer_total"] = self.tranfer_total
        _dict["fill_name"] = self.fill_name
        _dict["fill_date"] = self.fill_date
        _dict["calculate_id"] = self.calculate_id
        return _dict

#计算上传的附件
class  Calculate_attachments(models.Model):
    file = models.FileField(u'文件',upload_to= 'static\\upload\\%Y\\%m-%d',null=True,blank=True)
    file_name = models.CharField(u'文件名',max_length = 50)
    def getObj(self):
        _dict ={}
        _dict["id"] = self.id
        _dict["file_name"] = self.file_name
        _dict["file"] = self.file
        return _dict

# 重点环境管理危险化学品及其特征化学污染物释放与转移计算过程
#  表二的第二部分
class Release_transfer_calculate(models.Model):
    #释放计算过程
    #列明重点环境管理危险化学品及其特征化学污染物向 大气 释放量的详细计算过程及核算依据，要详细说明采用的核算方法，计算公式，参数选择及具体计算过程
    gas_calculate = models.CharField(u'计算过程(大气)',max_length = 500)
    gas_file_ids = models.CharField(u'添加说明文档(大气)',max_length = 50)
    #gas_calculate_file =models.FileField(u'添加说明文档(大气)',upload_to= 'static\\upload\\%Y\\%m-%d',null=True,blank=True)

    #列明重点环境管理危险化学品及其特征化学污染物向 土壤 释放量的详细计算过程及核算依据，要详细说明采用的核算方法，计算公式，参数选择及具体计算过程
    soil_calculate = models.CharField(u'计算过程(土壤)',max_length = 500)
    soil_file_ids = models.CharField(u'添加说明文档(土壤)',max_length = 50)
    #soil_calculate_file =models.FileField(u'添加说明文档(土壤)',upload_to= 'static\\upload\\%Y\\%m-%d',null=True,blank=True)


    #列明重点环境管理危险化学品及其特征化学污染物向 水体 释放量的详细计算过程及核算依据，要详细说明采用的核算方法，计算公式，参数选择及具体计算过程
    water_calculate = models.CharField(u'计算过程(水体)',max_length = 500)
    water_file_ids = models.CharField(u'添加说明文档(水体)',max_length = 50)
    #water_calculate_file =models.FileField(u'添加说明文档(水体)',upload_to= 'static\\upload\\%Y\\%m-%d',null=True,blank=True)

    #转移计算过程
    #列明重点环境管理危险化学品及其特征化学污染物向 污水处理厂 转移量的详细计算过程及核算依据，要详细说明采用的核算方法，计算公式，参数选择及具体计算过程
    to_processing_factory = models.CharField(u'计算过程(污水处理厂)',max_length = 500)
    to_processing_factory_file_ids = models.CharField(u'添加说明文档(污水处理厂)',max_length = 50)
    #to_processing_factory_file =models.FileField(u'添加说明文档(污水处理厂)',upload_to= 'static\\upload\\%Y\\%m-%d',null=True,blank=True)

    #列明重点环境管理危险化学品及其特征化学污染物向 固体废物处置单位 转移量的详细计算过程及核算依据，要详细说明采用的核算方法，计算公式，参数选择及具体计算过程
    to_solid_processing_unit = models.CharField(u'计算过程(固体废物处置单位)',max_length = 500)
    to_solid_processing_unit_file_ids = models.CharField(u'添加说明文档(污水处理厂)',max_length = 50)
    #to_solid_processing_unit_file =models.FileField(u'添加说明文档(污水处理厂)',upload_to= 'static\\upload\\%Y\\%m-%d',null=True,blank=True)

    def getObj(self):
        _dict ={}
        _dict["id"] = self.id
        _dict["gas_calculate"] = self.gas_calculate
        _dict["gas_file_ids"] = self.gas_file_ids
        _dict["soil_calculate"] = self.soil_calculate
        _dict["soil_file_ids"] = self.soil_file_ids
        _dict["water_calculate"] = self.water_calculate
        _dict["water_file_ids"] = self.water_file_ids
        _dict["to_processing_factory"] = self.to_processing_factory
        _dict["to_processing_factory_file_ids"] = self.to_processing_factory_file_ids
        _dict["to_solid_processing_unit"] = self.to_solid_processing_unit
        _dict["to_solid_processing_unit_file_ids"] = self.to_solid_processing_unit_file_ids
        return _dict

# 重点环境管理危险化学品及其特征化学污染物释放与转移情况汇总
#  表三
